<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace App\Admin\Request;

use Mine\MineFormRequest;

/**
 * 订单保险配置验证数据类
 */
class InsuranceRequest extends MineFormRequest
{
    /**
     * 公共规则
     */
    public function commonRules(): array
    {
        return [];
    }
    
    /**
     * 新增数据验证规则
     * return array
     */
    public function saveRules(): array
    {
        return [
            //保险等级 验证
            'level' => 'required|integer|in:1,2,3',
            //名称 验证
            'name' => 'required|string|max:10',
            //车损保障 验证
            'car_damage' => 'required|string|max:10',
            //车损保障副描述 验证
            'car_damage_sub' => 'required|string|max:10',
            //三者保障 验证
            'tripartite' => 'required|string|max:10',
            //乘客保障 验证
            'passenger' => 'required|string|max:10',
            //免折旧费 验证
            'free_depreciation' => 'required|integer|in:0,1',
            //无需垫付 验证
            'no_need_advance' => 'required|integer|in:0,1',
            //免停运费 验证
            'free_outage' => 'required|integer|in:0,1',
            //原本单价(天) 验证
            'original_price' => 'required|integer|between:0,65535',
            //单价(天) 验证
            'price' => 'required|integer|between:0,65535',
            //详情 验证
            'detail' => 'required|string',
        ];
    }

    /**
     * 更新数据验证规则
     * return array
     */
    public function updateRules(): array
    {
        return $this->saveRules();
    }

    
    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '',
            'level' => '保险等级',
            'name' => '名称',
            'car_damage' => '车损保障',
            'car_damage_sub' => '车损保障副描述',
            'tripartite' => '三者保障',
            'passenger' => '乘客保障',
            'free_depreciation' => '免折旧费',
            'no_need_advance' => '无需垫付',
            'free_outage' => '免停运费',
            'original_price' => '原本单价(天)',
            'price' => '单价(天)',
            'detail' => '详情',
            'car_id' => '绑定车辆',
        ];
    }
}